package cn.sciento.boot.api.customize.groovy;

import java.util.Objects;
import org.kohsuke.groovy.sandbox.GroovyInterceptor;

public class NoSystemExitSandbox extends GroovyInterceptor {
  private static final String EXIT = "exit";
  
  public Object onStaticCall(Invoker invoker, Class receiver, String method, Object... args) throws Throwable {
    if (receiver == System.class && Objects.equals(method, "exit"))
      throw new SecurityException("No call on System.exit() please"); 
    return super.onStaticCall(invoker, receiver, method, args);
  }
}
